package org.example.enums;


import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

@Getter
public enum RoleType {
    ALL_DATA(1, "全部数据"),
    INSTITUTIONAL_DATA(2, "本机构数据"),
    INDIVIDUAL_DATA(3, "个人数据")
    ;
    @EnumValue // 往数据库传的值
    private final int value;
    @JsonValue
    private final String desc;
    
    RoleType(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }
    
    public static RoleType fromValue(int value) {
        for (RoleType roleType : RoleType.values()) {
            if (roleType.getValue() == value) {
                return roleType;
            }
        }
        throw new IllegalArgumentException("Unknown role type: " + value);
    }
}
